layui.config({
    base: '/layui/extend/'
}).use(['form', 'layer', 'dtree', 'rate'], function () {
    $ = layui.jquery;
    var form = layui.form
        , layer = parent.layer === undefined ? layui.layer : top.layer

    var rate = layui.rate;
    //显示文字
    var instance = rate.render({
        elem: '#score'
        ,value: score //初始值
        ,text: true //开启文本
        ,choose: function (value) {
            console.log(value)
            rate.render({
                elem: '#score'
                ,value: value //初始值
                ,text: true //开启文本
                ,readonly: true
            })
        }
    });

    form.on('submit(confirm)', function (form) {
        index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        var url = "/document/check";
        form.field.score = instance.config.value;
        form.field.document_id = document_id;
        console.log(form.field);
        $.post(url, form.field, function (res) {
            res = eval("("+res+")")
            if(res.code==200) {
                setTimeout(function () {
                    top.layer.close(index);
                    top.layer.msg("操作成功！",{icon: 6});
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
                }, 500);
            } else {
                layer.msg(
                    res.message, {
                        icon: 5
                    }
                )
            }
        })
        return false;
    });

    //无用代码
    // form.on('submit(update)', function (form) {
    //     index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
    //     // form.field.role = formSelects.value('role-select', 'val');
    //     var url = "/document/updateCheck";
    //     console.log(form.field);
    //     $.post(url, form.field, function (res) {
    //         res = eval("("+res+")")
    //         if(res.code==200) {
    //             setTimeout(function () {
    //                 top.layer.close(index);
    //                 top.layer.msg("操作成功！",{icon: 6});
    //                 layer.closeAll("iframe");
    //                 //刷新父页面
    //                 parent.location.reload();
    //             }, 500);
    //         } else {
    //             layer.msg(
    //                 res.message, {
    //                     icon: 5
    //                 }
    //             )
    //         }
    //     })
    //     return false;
    // });
});